#!/bin/bash
# $1 删除类型 
# $2 目录
# $3 域名类型
# $4 域名
# $5 端口

# 判断正式域名还是临时域名
if [ $3 -eq 1 ];then
  a=$4
  OLD_IFS="$IFS"
  IFS=","
  arr=($a)
  IFS="$OLD_IFS"
  sname=${arr[0]}

  sed -i ":n;/ServerName $sname/,+4d;/\n.*\n/!{N;bn};P;D" /etc/httpd/conf/extra/dc-site.conf
  sed -i '/./,/^$/!d' /etc/httpd/conf/extra/dc-site.conf
else
  sed -i "/$5/,+13d" /etc/httpd/conf/extra/dc-temp.conf
  sed -i '/./,/^$/!d' /etc/httpd/conf/extra/dc-temp.conf
fi

# 重新载入apache
#if [ $? -eq 0 ];then
#  service httpd reload > /dev/null 2>&1
#fi

#如果要删除目录
if [ $1 -eq 2 ];then
  if [ -n "$2" ]; then  
    rm -rf /www/web/$2 > /dev/null 2>&1
  fi
fi

echo success
